<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style>
        canvas {
            background: black;
        }
    </style>
</head>

<body>
    <canvas id="canvas"></canvas>

    <script>
        const canvas = document.querySelector("#canvas");
        const ctx = canvas.getContext("2d");
        //加载图片
        const img = new Image();

        img.onload = function () {
            canvas.width = img.width;
            canvas.height = img.height;
            ctx.drawImage(img, 0, 0);
            ctx.lineWidth = 0.5;
            ctx.strokeStyle = "rgb(255, 255, 255)";
            //横线
            drawLine(0, 20, canvas.width, 20);
            drawLine(0, 170, canvas.width, 170);
            drawLine(0, 190, canvas.width, 190);
            drawLine(0, 340, canvas.width, 340);
            drawLine(0, 360, canvas.width, 360);
            drawLine(0, 530, canvas.width, 530);
            drawLine(0, 550, canvas.width, 550);
            //竖线
            drawLine(70, 0, 70, canvas.height);
            drawLine(90, 0, 90, canvas.height);
            drawLine(180, 0, 180, canvas.height);
            drawLine(200, 0, 200, canvas.height);
            drawLine(290, 0, 290, canvas.height);
            drawLine(310, 0, 310, canvas.height);
            //点
            draawDot(110,177)
            draawDot(135,162)
            draawDot(180,169)
            draawDot(196,185)
           
        };

        img.src = "./imgs/demo.png";
        
        //画线
        function drawLine(x1, y1, x2, y2) {
            ctx.beginPath(); //不写每次都会重绘上次的线
            ctx.moveTo(x1, y1);
            ctx.lineTo(x2, y2);
            ctx.stroke();
        }
        function draawDot(x1,y1,r) {
            ctx.beginPath(); //不写会和线连起来
            ctx.fillStyle="red";
            //绘制
            ctx.arc(x1,y1,r?r:2,0,2*Math.PI);
            ctx.fill()
        }
    </script>
</body>

</html>